home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Trading on the Edge
/
Trading On The Edge - CD-ROM Toolkit (Wayzata Technology)(2031)(1994).bin
/
pc
/
mac_file
/
vendor_d
/
neuralwa
/
nw2v50
/
twod_map.c
< prev
next >
Wrap
Text File
|
1993-08-23
|
8KB
|
404 lines
/* twod_map.c */
/* 2 input node, 1 output node userio program */
/* Assumptions:
(a) x,y Values in file are assumed to lie between
-1.5 and 1.5.
(b) output value between 0 and 1
If used with save-best, set objective function to be UserIO.
*/
/************************************************************************
* Copyright(C) 1987-1992 NeuralWare Inc *
* Penn Center West, IV-227, Pittsburgh, PA 15276 *
* Telephone: (412) 787-8222 FAX: (412) 787-8220 *
* *
* All rights reserved. No part of this program may be reproduced, *
* stored in a retrieval system, or transmitted, in any form or by any *
* means, electronic, mechanical, photocopying, recording or otherwise *
* without the prior written permission of the copyright owner, *
* NeuralWare, Inc. *
* *
* PROPRIETARY NOTICE *
* *
* This document is the property of NeuralWare, Inc. and contains *
* trade-secrets and other proprietary information. The information *
* herein is reserved as proprietary to NeuralWare, and is not to be *
* published, reproduced, copied, disclosed, used, or reverse *
* engineered without the express written consent of a duly authorized *
* representative of NeuralWare. *
************************************************************************
*/
#define UIO_SERVER 1
#define SERVER_EMULATOR_FILE 1
#define SKIP_COMPAT_DATA 1
#include "userutl.h"
#include "uio_strc.h"
#include "uio_tran.h"
#include "uio_reqs.pro"
#include "uio_cmds.pro"
#include <math.h>
#ifdef MAC
#include "macuio.redef"
#endif
#define DO_BLIT 1
#define W_WDTH 200 /* basic defining parameters */
#define W_HGHT 200 /* height of graph */
long file_count = 0l;
#define SBUF_ALC 200
TEXT sbuf[SBUF_ALC];
int back_color;
int on_color;
#define COLOR_MAX 12
int color[COLOR_MAX];
int savebestf; /* Save best flag */
float xin, yin; /* Real coords of recall point */
int x_rcl, y_rcl; /* Graphics coords of recall point */
#define W0 1
#define W1 2
#define PIXEL_WIDTH 3
#ifdef DO_BLIT
#define BLIT_DIMX (((W_WDTH-1)/PIXEL_WIDTH)+1)
#define BLIT_DIMY (((W_HGHT-1)/PIXEL_WIDTH)+1)
TEXT blit[BLIT_DIMY][BLIT_DIMX];
#endif
NINT UIO_Init(file)
TEXT *file;
{
NINT ret_val = UIO_OK;
NINT xsize, ysize, ncolor, chrx, chry; /* graphics parameters */
NINT ypos;
TEXT *filen;
FILE *fp;
savebestf = 0;
/* Get screen parameters */
ug_gparms( &xsize, &ysize, &ncolor, &chrx, &chry);
if ( ncolor < 8 ) {
color[0] = 0;
color[1] = 0;
color[2] = 0;
color[3] = 0;
color[4] = 0;
color[5] = 0;
color[6] = 1;
color[7] = 1;
color[8] = 1;
color[9] = 1;
color[10] = 1;
color[11] = 1;
on_color = 1;
} else {
color[0] = 4;
color[1] = 4;
color[2] = 4;
color[3] = 11;
color[4] = 11;
color[5] = 7;
color[6] = 7;
color[7] = 9;
color[8] = 9;
color[9] = 1;
color[10] = 1;
color[11] = 1;
on_color = 6;
}
back_color = color[0];
ypos = ysize - W_HGHT - 100;
if (ypos < 75)
ypos = 95;
if (ypos > 300)
ypos = 300;
/* Set up windows */
ug_window(W0, back_color, 20, ypos+25, 20+W_WDTH, ypos+25+W_HGHT);
ug_window(W1, 0, 20, ypos, 20+W_WDTH, ypos+24);
/* Get file count so we can calculate epochs */
ug_rdfileinf(&filen,0,&file_count);
if (file_count <= 0l)
file_count = 1l;
return(ret_val);
}
NINT UIO_Term(process)
NINT process;
{
NINT ret_val = UIO_OK;
return(ret_val);
}
NINT UIO_Attention()
{
NINT ret_val = UIO_OK;
return(ret_val);
}
NINT UIO_Learn_Start()
{
NINT ret_val = UIO_OK;
/* Set up learn file; use selected file */
ug_fileio("", 0, 1, 1, 1);
return(ret_val);
}
NINT UIO_Learn_Input(LayN, nPEs, Datap)
NINT LayN;
NINT nPEs;
SREAL *Datap;
{
NINT ret_val = UIO_OK;
return(ret_val);
}
NINT UIO_Learn_Output(LayN, nPEs, Datap)
NINT LayN;
NINT nPEs;
SREAL *Datap;
{
NINT ret_val = UIO_OK;
return(ret_val);
}
NINT UIO_Learn_Result(LayN, nPEs, Datap)
NINT LayN;
NINT nPEs;
SREAL *Datap;
{
NINT ret_val = UIO_OK;
return(ret_val);
}
NINT UIO_Learn_End()
{
NINT ret_val = UIO_OK;
return(ret_val);
}
NINT UIO_Recall_Start()
{
NINT ret_val = UIO_OK;
TEXT *sp;
CTRIO_T ctrs[8]; /* Counters */
NINT epch;
x_rcl = PIXEL_WIDTH>>1;
y_rcl = PIXEL_WIDTH>>1;
#ifdef DO_BLIT
PutStr("Testing ...");
#else
ug_winclr(W0);
ug_winclr(W1);
/* Read counters to get learn count */
ug_ctrio(ctrs,0);
epch = ctrs[2]/((float)file_count);
sprintf(sbuf,"Epoch: %ld", (long)epch);
ug_puts(W1,on_color,0,15,4,sbuf,0);
#endif
return(ret_val);
}
NINT UIO_Read(LayN, nPEs, Datap)
NINT LayN;
NINT nPEs;
SREAL *Datap;
{
NINT ret_val = UIO_OK;
/* Assume data lies between -1.5 and 1,5 */
xin = ((3*x_rcl) / (float)W_WDTH) - 1.5;
yin = ((3*y_rcl) / (float)W_HGHT) - 1.5;
Datap[0] = xin;
Datap[1] = yin;
return(ret_val);
}
NINT UIO_Write(LayN, nPEs, Datap)
NINT LayN;
NINT nPEs;
SREAL *Datap;
{
NINT ret_val = UIO_OK;
SREAL outval;
NINT wx;
#ifdef DO_BLIT
NINT blitx, blity;
#endif
outval = Datap[0];
wx = (COLOR_MAX*outval);
if (wx >= COLOR_MAX)
wx = COLOR_MAX-1;
else if (wx < 0)
wx = 0;
#ifdef DO_BLIT
blitx = (x_rcl-1)/PIXEL_WIDTH;
blity = (y_rcl-1)/PIXEL_WIDTH;
blit[blity][blitx] = color[wx];
#else
if (color[wx] != back_color)
ug_boxf(W0, color[wx], 0,
x_rcl-1,y_rcl-1,x_rcl+1,y_rcl+1);
#endif
x_rcl += PIXEL_WIDTH;
if (x_rcl > W_WDTH) {
x_rcl = PIXEL_WIDTH>>1;
y_rcl += PIXEL_WIDTH;
#ifdef DO_BLIT
/* Want to know we're still alive */
PutStr(".");
#endif
}
#ifdef DO_BLIT
/* End of recall; now BLIT the image */
if (y_rcl >= W_HGHT) {
CTRIO_T ctrs[8]; /* Counters */
NINT epch;
ug_winclr(W0);
ug_winclr(W1);
ug_blit(W0, 0, 0, 0, PIXEL_WIDTH, PIXEL_WIDTH,
BLIT_DIMX, BLIT_DIMY, (char *)&blit[0][0] );
/* Read counters to get learn count */
ug_ctrio(ctrs,0);
epch = ctrs[2]/((float)file_count);
sprintf(sbuf,"Epoch: %ld", (long)epch);
ug_puts(W1,on_color,0,15,4,sbuf,0);
PutStr("\n");
}
#endif
if (y_rcl >= W_HGHT)
return( UIO_EXIT);
else
return( UIO_OK);
}
NINT UIO_Write_Step(LayN, nPEs, Datap)
NINT LayN;
NINT nPEs;
SREAL *Datap;
{
NINT ret_val = UIO_OK;
return(ret_val);
}
NINT UIO_Recall_Test(LayN, nPEs, Datap)
NINT LayN;
NINT nPEs;
SREAL *Datap;
{
NINT ret_val = UIO_OK;
return(ret_val);
}
NINT UIO_Recall_End()
{
NINT ret_val = UIO_OK;
if (!savebestf) {
PutStr("Hit <Enter> to continue:");
GetStr( );
}
return(ret_val);
}
NINT UIO_Instrument(Instrument_id, nDataElems, DataElemp)
NINT Instrument_id;
NINT nDataElems;
SREAL *DataElemp;
{
NINT ret_val = UIO_OK;
return(ret_val);
}
/* FUNCTION */
NINT UIO_ObjFunc(eoeflag, DataElemp)
NINT eoeflag;
SREAL *DataElemp;
{
NINT ret_val = UIO_OK;
if (eoeflag)
savebestf = 0; /* Clear save best flag */
else
savebestf = 1; /* Tell recall we are in savebest mode */
return(ret_val);
}
NINT UIO_Rewind()
{
NINT ret_val = UIO_OK;
return(ret_val);
}
NINT UIO_Explain(LayN, nPEs, Datap)
NINT LayN;
NINT nPEs;
SREAL *Datap;
{
NINT ret_val = UIO_OK;
return(ret_val);
}